package top.chj.day16.dateclass;

import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;

/**
 * @Auther:小陈的Java
 */
public class OldDateDemo{
    @Test
    public void test1(){
        long end = new Date().getTime();
        Calendar calendar = Calendar.getInstance();
        calendar.set(2012,11,12);
        long start = calendar.getTime().getTime();
        long result =end-start;
        System.out.println(result/1000/60/60/24);
        long day = ChronoUnit.DAYS.between(LocalDate.of(2012,11,12),LocalDate.now());
        System.out.println(day);
    }
    @Test
    public void test2(){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for(int i = 0; i<2;i++){
            new Thread(){
                @Override
                public void run() {
                    try {
                        System.out.println(simpleDateFormat.parse("2012-11-12 12:12:12"));
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                }
            }.start();
        }
    }


}
